const dbMod = require('../db/dbMod');
// const async = require('async');

function login (userAccount, callback) {
    let accountSQL = 'SELECT userID, userAccount, password, userPower, userStatus FROM account where userAccount = ?';
    //传入三个参数，第一个参数sql语句，第二个参数sql语句中需要的数据，第三个参数回调函数
    dbMod.query(accountSQL, [userAccount], function (result) {
        console.log('查询结果：');
        //console.log(result);
        var accountResult = eval(result);
        callback(accountResult);
        //  return callback = accountResult;
    });
}

function getByID (userID, callback) {
    let sql = 'SELECT * FROM account WHERE userID=?'
    dbMod.query(sql, [userID], (result) => {
        callback(eval(result))
    })
}

exports.login = login;
exports.getByID = getByID